package edu.ubb.remeye.encodings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Enumeration of encoding types.
 * 
 * @author Andrew Ianicicau
 *
 */
public enum EncodingType {

	///////////////////////////////////////////////////////////////////////////////////
	////		ATTRIBUTES - EncodingType
	///////////////////////////////////////////////////////////////////////////////////

	/**
	 * BMP format encoding.
	 */
	BMP,
	
	/**
	 * JPEG format encoding.
	 */
	JPEG,
	
	/**
	 * PNG format encoding.
	 */
	PNG;

	
	
	///////////////////////////////////////////////////////////////////////////////////
	////		METHODS - EncodingType
	///////////////////////////////////////////////////////////////////////////////////
	
	/**
	 * Returns the encoding type associated to the given ordinal. BMP is default.
	 * @param ordinal Encoding type ordinal.
	 * @return Encoding type associated to ordinal.
	 */
	public static EncodingType getEncodingType(int ordinal) {
		switch(ordinal) {
		case 0:
			return BMP;
		case 1:
			return JPEG;
		case 2:
			return PNG;
		default:
			return BMP;
		}
	}
	
	/**
	 * Returns the list of encoding types available.
	 * @return The list of encoding types. 
	 */
	public static List<EncodingType> getEncodingTypeList() {
		List<EncodingType> list = new ArrayList<EncodingType>(); 
		list.addAll(Arrays.asList(EncodingType.values()));
		return list;
	}
	
	/**
	 * Returns the encoding type if exists in the given list, otherwise BMP encoding type. 
	 * @param list The list of encoding types to use.
	 * @param type The encoding type to check for in the list.
	 * @return Encoding type or invalid.
	 */
	public static EncodingType listContains(List<EncodingType> list, EncodingType type) {
		if(list.contains(type))
			return type;
		return BMP;
	}

}
